<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>H+ 后台主题UI框架 - 空白页</title>

    <link rel="shortcut icon" href="__STATIC__/layout/favicon.ico">
  <link href="__STATIC__/layout/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__STATIC__/layout/css/font-awesome.css?v=4.4.0" rel="stylesheet">
     <!-- jqgrid-->
    <link href="__STATIC__/layout/css/animate.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/style.css?v=4.1.0" rel="stylesheet">
  
    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
      <link href="__STATIC__/layout/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
      <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
</head>

<body class="white-bg" style="color:#333;padding:0px;">
    <div class="page-heade">
      <h2 class="title_color text-center">分组经销商管理</h2>
    </div>
        <div class="Agencycontent">
        <form action="#" class="form-inline">
        <input type="hidden" id="gid" value="{$group.id}"/>
             <table class="table table-bordered">
                      <tr>
                        <td style="min-width: 140px;width: 140px"><label for="">经销商名称:</label></td>
                        <td><input type="text" id="group_name" class="form-control"></td>
                        <td style="min-width: 140px;width: 140px"><label for="">选择查询列表:</label></td>
                        <td>
                          <select name="" id="types" class="form-control">
                              <option value="0">没分组的经销商</option>
                              <option value="1">{$group.group_name}</option>
                          </select>
                        </td>
                     </tr>
                    <tr>
                      <td class="text-center" colspan="4">
                          <button class="btn-info btn query" type="button" id="ck">查询</button>
                          <button class="btn-info btn emptyIf" type="button" id="clearck">清空查询条件</button>
                      </td>
                    </tr>
             </table>
           <table class="table table-bordered">
           <tr>
              <td class="text-center info" style="font-size: 16px">没分组的经销商</div></td>
              <td></td>
              <td class="info text-center" style="font-size: 16px">{$group.group_name}</td>
           </tr>
           <tr><td class="col-md-5" style="height:600px; overflow:auto;">
                  <select multiple id="select1" style="height: 100%;width: 100%" class="form-control">
                         {volist name="nojarr" id="is"}
                        <option value="{$is.id}">{$is.title}</option>
                     {/volist}
                         </select>
                     </td>
                     <td class="col-md-2 text-center">
                   <span style="border-radius: 6px;padding:5px 10px;cursor: pointer; border:1px solid #ccc;margin-left: 25px;" id="toRight">&gt;&gt;&gt;&gt;&gt;&gt;</span>
                   <br/> <br/> <br/> <br/>
                    <span style="border-radius: 6px;padding:5px 10px;cursor: pointer; border:1px solid #ccc;margin-left: 25px;" id="toLeft">&lt;&lt;&lt;&lt;&lt;&lt;</span>
            </td>
            <td class="col-md-5"  style="height:600px; overflow:auto;">
                  <select multiple id="select2" style="height: 100%;width: 100%" class="form-control">
                     {volist name="jarr" id="is"}
                        <option value="{$is.id}">{$is.title}</option>
                     {/volist}
                         </select>
            </td>
           </tr>
            </table>
              <div class="row white-bg text-center" style="padding:15px 0">
            <button class="btn btn-warning" onclick="back()" type="button">返回</button>
        </div>
        </form>
    </div>
    <!-- 表格 -->



    <!-- 全局js -->
       <!-- 全局js -->
    <script src="__STATIC__/layout/js/jquery.min.js?v=2.1.4"></script>
    <script src="__STATIC__/layout/js/bootstrap.min.js?v=3.3.6"></script>
    <!-- <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script> -->
    <script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
    <script src="__STATIC__/layout/js/plugins/sweetalert/sweetalert.min.js"></script>
<script src="__STATIC__/layout/js/plugins/layer/layer.min.js"></script>
    <script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="__STATIC__/layout/js/plugins/summernote/summernote.min.js"></script>
<script src="__STATIC__/layout/js/plugins/summernote/summernote-zh-CN.js"></script>
<script src="__STATIC__/layout/js/plugins/suggest/bootstrap-suggest.min.js"></script>
      <script src="__STATIC__/layout/js/common.js"></script>
    <!-- <script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script> -->
    <script>
    $("#clearck").click(function(){
      $("#group_name").val('');
       $("#select1 option").prop("selected",false);
        $("#select2 option").prop("selected",false);
    })
    $("#ck").click(function(){
      var gpname=$("#group_name").val();
      if(gpname==""){
        swal({
                              title: "错误",
                              text:  "查询经销商名不能为空",
                              type: "warning"
                              });
      }else{
        //可查询
        $("#select1 option").prop("selected",false);
        $("#select2 option").prop("selected",false);
        if($("#types").val()==0){
          //无分组
          var flag=0;
          $("#select1 option").each(function(){
            if($(this).html()==gpname){
              $(this).prop("selected",true);
              flag=1;return false;
            }
          })
          if(flag==0){
              swal({
                              title: "错误",
                              text:  "没有查询到此经销商",
                              type: "warning"
                              });
          }
        }else{
           //有分组
          var flag=0;
          $("#select2 option").each(function(){
            if($(this).html()==gpname){
              $(this).prop("selected",true);
              flag=1;return false;
            }
          })
          if(flag==0){
              swal({
                              title: "错误",
                              text:  "没有查询到此经销商",
                              type: "warning"
                              });
          }
        }
      }
    })
        $(document).ready(function() {
                $('#toRight').click(function() {
                    var $options = $('#select1 option:selected'); //获取选中的元素
                    var arr=[];
                    $('#select1 option:selected').each(function(){
                      arr.push($(this).val());
                    })
                    var jids=arr.join(',');
                   // alert(jids);
                   if(jids!=""){
                      $.post("{:url('addjxs')}",{gid:$("#gid").val(),jid:jids},function(re){
                        //alert(re);
                        if(re==1){
                           var $remove = $options.remove();
                            $remove.appendTo('#select2');
                        }else{
                           swal({
                              title: "错误",
                              text:  "系统繁忙请稍后再试",
                              type: "warning"
                              });
                        }
                      })
                     
                   }
                  
                });
                 $('#toLeft').click(function() {
                    var $options = $('#select2 option:selected'); //获取选中的元素
                     var arr=[];
                    $('#select2 option:selected').each(function(){
                      arr.push($(this).val());
                    })

                    var jids=arr.join(',');
                    if(jids!=""){
                      $.post("{:url('canceljxs')}",{jid:jids},function(re){
                        //alert(re);
                        if(re==1){
                           var $remove = $options.remove();
                            $remove.appendTo('#select1');
                        }else{
                           swal({
                              title: "错误",
                              text:  "系统繁忙请稍后再试",
                              type: "warning"
                              });
                        }
                      })
                     
                   }
                });
            })
        function back(){
           location.href="{:url('manage')}";
        }
   </script>
</body>

</html>